source('00_util_scripts/mod_bplot.R')
library(tidyverse)
# BiocManager::install('pheatmap')

cross_presentation_genes <- c(
  "HLA-A", "HLA-B", "HLA-C", "B2M", 
  "TAP1", "TAP2", "ERAP1", "ERAP2", "CLEC9A", "BATF3",
  "CALR", "CANX", "CLEC9A", "FCGR1A", "FCGR2A", "FCGR2B", "FCGR3A", "FCGR3B", 
  "CD36", "SEC61A1", "SEC61B", "SEC61G", "VAMP8", "CD40", "CD40LG", 
  "TLR1", "TLR2", "TLR3", "TLR4", "TLR5", "TLR6", "TLR7", "TLR8", "TLR9", 
  "RAB7A", "HSPA1A", "HSPA1B", "HSP90AA1", 'RAB27A',
  'TAPBP', 'TAPBPL', 'PSMB8', 'PSMB9', 'PSMB10', 'IFI30'
) |> str_to_title() |> unique()

gelvpbs <- read_csv('mission/DNA-gel/DEG_Gel_vs_PBS.High_in_Gel.csv')

gelvpbs |>
  filter(genename %in% cross_presentation_genes) |>
  mutate(genename = fct_reorder(genename, logFC)) |>
  ggplot(aes(logFC, genename, fill = padj)) +
  geom_col() +
  scale_fill_distiller(palette = 'Reds') +
  labs(y = 'Gene', title = 'Gel vs PBS: Cross-presentation associated genes') +
  theme_bw()

upcp <- gelvpbs |>
  filter(genename %in% cross_presentation_genes) |>
  pull(genename)
  
fpkm <- read_delim('mission/DNA-gel/FPKM_DEG_Summary.txt')

problems(fpkm)

fpkm |>
  filter(genename %in% cross_presentation_genes) |>
  dplyr::select(genename:PBS3_FPKM) |>
  column_to_rownames('genename') |>
  pheatmap::pheatmap(scale = 'row', main = 'Cross-presentation related genes')

fpkm |>
  filter(genename %in% upcp) |>
  dplyr::select(genename:PBS3_FPKM) |>
  arrange(genename) |>
  column_to_rownames('genename') |>
  pheatmap::pheatmap(scale = 'row', cluster_rows = F,
                     main = 'Upregulated cross-presentation related genes')
